<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="java.util.List, manager.*,book.*, member.*" %>
<%
	// リクエスト文字列のエンコードを設定
	request.setCharacterEncoding("UTF-8");
	// パラメータの取得
	Integer crtPage = (Integer)request.getAttribute("page");
	Integer cnt = (Integer)request.getAttribute("cnt");
	if(cnt==null)
	{
		cnt=0;
	}
	String msg = String.format("該当者%d人", cnt);
	
	@SuppressWarnings("unchecked")
	List<RentalBean> list = (List<RentalBean>)request.getAttribute("list");
	@SuppressWarnings("unchecked")
	List<MemberBean> listAppend = (List<MemberBean>)request.getAttribute("listAppend");
%>
<jsp:include page="/share/layout.jsp">
    <jsp:param name="title" value="本返却者一覧"/>
    <jsp:param name="css" value="manager.css"/>
    <jsp:param name="content">
        <jsp:attribute name="value">
<!-- contents start -->
<% if(list!=null) { %>

<% if(msg != null && !"".equals(msg)) { %>
<div id="msg_area">
	<%= msg %>
</div>
<% } %>

<form id="mng_form" action="MailCheckServlet">
	<table class="list_table">
		<tr>
			<th id="user_id" colspan="2">メールアドレス</th>
			<th id="members_name">氏名</th>
			<th id="members_ruby">カナ</th>
			<th id="rental_date">貸出日</th>
			<th id="return_date">返却日</th>
		</tr>
		<%
		for(int i=0; i<list.size(); i++) {
			RentalBean rentals = list.get(i);
			MemberBean members=listAppend.get(i);
		%>
		<tr <% if(i%2!=0){ out.print("class=\"color\""); } %>>
			<td align="center"><input type="radio" name="user_id" value="<%= members.getUserId() %>" /></td>
			<td><%= members.getUserId() %></td>
			<td><%= members.getName() %></td>
			<td><%= members.getRuby() %></td>
			<td align="center"><%=rentals.getRentalDate() %></td>
			<td align="center"><%=rentals.getReturnDate()  %></td>
		</tr>
		<%
		}
		%>
	</table>

	<div id="paging_area">
		<% if(crtPage > 1) { %>
			<a href="/Books/manager/ListServlet?page=<%= crtPage-1 %>">前へ</a>
		<% } %>
		<% for(int i=0, p=1; i<cnt; i+=10, p++) { %>
			<a href="/Books/manager/ListServlet?page=<%= p %>"><%= p %></a>
		<% } %>
		<% if(crtPage * 10 < cnt) { %>
			<a href="/Books/manager/ListServlet?page=<%= crtPage+1 %>">次へ</a>
		<% } %>
	</div>
	
<%} 

else { %>
	<div id="msg_area">
	<%= msg %>
</div>
	<h3 align="center">リストがありません</h3>
<%} %>

	<input class="button" type="submit" name="back" value="戻る" />
	<input class="button" type="submit" name="delete" value="メール編集" />
	<input class="button" type="submit" name="edit" value="返却" />

</form>
<!-- contents end -->
        </jsp:attribute>
    </jsp:param>
</jsp:include>